﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PolarSyncApp
{
    static class Helpers
    {
        public static TResult Invoke<T, TResult>(this T controlToInvokeOn, Func<TResult> code) where T : Control
        {
            if (controlToInvokeOn.InvokeRequired)
            {
                return (TResult)controlToInvokeOn.Invoke(code);
            }
            else
            {
                return (TResult)code();
            }
        }
    }
}
